package com.zenithsun.common.security.xss;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.*;


import java.io.IOException;

/**
 * XSS 漏洞处理标签
 * @author Jiang
 */
public class XSSFilterTag extends SimpleTagSupport {

    /**
     * 生成CSRF token Tag
     * @throws JspException
     * @throws IOException
     */
    @Override
    public void doTag() throws JspException, IOException {
        PageContext ctx = (PageContext) getJspContext();
        JspWriter out = ctx.getOut();
        //XSS 特殊字符过滤
        String afterXssValue = XSSFilterManager.xssEncode(getValue());
        out.print(afterXssValue);
    }
    
    private String value;
    
    public void setValue(String value) {
		this.value = value;
	}
    
    public String getValue() {
		return value;
	}
}
